<template>
	<view class="page-content">
		<view class="searchBox">
			<m-search :search_list="search_list" @search="search" placeholder="请输入关键词"></m-search>
		</view>
		<view class="bg_fff">
			<u-tabs :list="typeList" @click="typeClick" lineColor="#333333" keyName="name"
				:activeStyle="{fontWeight: 'bold',color: '#333333',transform: 'scale(1.2)'}"
				:itemStyle="{width:'30%',marginBottom:'20rpx'}"
				:inactiveStyle="{color: '#999999', transform: 'scale(1)'}" :scrollable="false"></u-tabs>
		</view>
		<u-list v-if="dataList.length" :customStyle="{
			marginBottom: '20rpx',padding: '0rpx 20rpx',boxSizing: 'border-box',paddingTop: '20rpx'
			}" @scrolltolower="listScrollTolower">
			<keyword-item :data="item" @clickItem="clickListItem" v-for="(item, index) in dataList" :key="index"
				type="manage" @clickFeedBack="clickFeedBack">
			</keyword-item>
		</u-list>
		<u-empty mode="list" v-else :customStyle="{flex:'7'}"></u-empty>

		<u-tabbar :value="value" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true" activeColor="#C62B2C"
			inactiveColor="#707070">
			<u-tabbar-item text="首页" @click="clickBar1" name="bar1">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/homeactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../../static/img/tabbar/home.png">
				</image>
			</u-tabbar-item>
			<u-tabbar-item text="发布" @click="clickBar2" name="bar2">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/publishactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon"
					src="../../../static/img/tabbar/publish.png">
				</image>
			</u-tabbar-item>
			<u-tabbar-item text="动态" @click="clickBar3" v-if="showXt" name="bar3">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/courseactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../../static/img/tabbar/course.png">
				</image>
			</u-tabbar-item>
			<u-tabbar-item text="收益" @click="clickBar5" name="bar5">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/incomeactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../../static/img/tabbar/income.png">
				</image>
			</u-tabbar-item>
			<u-tabbar-item text="我的" @click="clickBar4" name="bar4">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/mineactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../../static/img/tabbar/mine.png">
				</image>
			</u-tabbar-item>
		</u-tabbar>

		<!-- <uni-popup ref="popup" type="bottom">
			<view class="bg_fff">
				<scroll-view scroll-y="true" class="list_box">
					<view class="acc_item" v-for="(item,index) in popData" :key="index" @click="feedbackAccount(item)">
						<view class="f_26 acc_plf c_666666 mb-10 pl-20"><text>{{item.ppname||"ppname"}}</text></view>
						<view class="mb-10 display_row_btn_center" style="justify-content: space-around;">
							<view><text space="emsp" class="f-24 c_666666">账户ID：</text><text
									class="f-30 c_000000">{{item.acc_id||"acc_id"}}</text></view>
							<view><text space="emsp" class="f-24 c_666666">昵 称：</text><text
									class="f-30 c_000000">{{item.nickname||"nickname"}}</text></view>
						</view>
						<u-line direction="row" color="#999999"></u-line>
					</view>
				</scroll-view>
			</view>
		</uni-popup> -->
	</view>
</template>

<script>
	import {
		getSearchData1,
		getKeyWords1,
		getConfig
	} from '@/config/api.js'
	export default {
		data() {
			return {
				showXt: false,
				value: 'bar2',
				typeList: [{
						id: 1,
						name: '待发布'
					},
					{
						id: 2,
						name: '进行中'
					},
					{
						id: 3,
						name: '已过期'
					},
				],
				dataList: [],
				page: 1,
				pages: 1,
				search_list: [],
				searchForm: {},
				dataList: [],
				userInfo: null,
				has_feedback: 1,
				popData: [],
				popitem: null
			}
		},
		onShow() {
			this.userInfo = uni.getStorageSync("UserInfo");

			this.dataList = [];
			this.page = 1;
			this.pages = 1;
			this.getSearch();
			this.getList();
			this.getcofg();
		},
		methods: {
			clickFeedBack(data) {
				if (data.feedBack.length <= 0) {
					uni.showToast({
						title: '未回填数据！',
						icon: 'none',
						duration: 2000
					})
					return;
				}

				uni.navigateTo({
					url: '/pages/mission/feebackList?mission_id=' + data.mission_id + "&keyword_id=" + data.id
				})

				// this.popData = data.feedBack;
				// this.popitem = data;

				// this.$refs.popup.open();
			},
			getcofg() {
				getConfig().then(res => {
					if (res.value == 1) {
						this.showXt = true
					} else {
						this.showXt = false
					}
				})
			},
			getSearch() {
				getSearchData1().then(res => {
					this.search_list = res;
				}).catch(err => {

				})
			},
			search(data) {
				this.searchForm = data;
				this.dataList = [];
				this.page = 1;
				this.pages = 1;
				this.getList();
			},
			typeClick(item) {
				this.has_feedback = item.id;
				this.dataList = [];
				this.page = 1;
				this.pages = 1;
				this.getList();
			},
			getList() {

				if (this.userInfo == null || this.userInfo == "") {
					return;
				}

				var subData = {
					status: 2,
					user_id: this.userInfo.id,
					page: this.page
				}

				if (this.searchForm?.search_input) {
					subData['keyword'] = this.searchForm.search_input;
				}

				if (this.searchForm?.choiseData?.Category) {
					subData['category_id'] = this.searchForm.choiseData.Category;
				}

				if (this.searchForm?.choiseData?.Platform) {
					subData['platform_flag'] = this.searchForm.choiseData.Platform;
				}

				if (this.has_feedback <= 2) {
					subData['has_feedback'] = this.has_feedback;
				} else {
					subData['is_over_time'] = true;
				}

				getKeyWords1(subData).then(res => {
					this.dataList = this.dataList.concat(res.list);
					this.pages = res.page.pages;
					this.page++;
				}).catch(err => {

				})
			},
			listScrollTolower() {
				if (this.page <= this.pages) {
					this.getList();
				}
			},
			onPageScroll(e) {
				uni.$emit('onPageScroll', e); //传递参数
			},
			onReachBottom(e) {
				uni.$emit('onReachBottom', e); //传递参数
			},
			onPullDownRefresh(e) {
				uni.stopPullDownRefresh();
			},
			clickBar1() {
				// this.value = 'bar1';
				uni.switchTab({
					url: '/pages/tabbar/tabbar-1/tabbar-1'
				})
			},
			clickBar2() {
				// this.value = 'bar2';
				uni.switchTab({
					url: '/pages/tabbar/tabbar-2/tabbar-2'
				})
			},
			clickBar3() {
				// this.value = 'bar3';
				uni.switchTab({
					url: '/pages/tabbar/tabbar-3/tabbar-3'
				})
			},
			clickBar4() {
				// this.value = 'bar4';
				uni.switchTab({
					url: '/pages/tabbar/tabbar-4/tabbar-4'
				})
			},
			clickFeedBack(data) {
				if (data.feedBack.length <= 0) {
					uni.showToast({
						title: '未回填数据！',
						icon: 'none',
						duration: 2000
					})
					return;
				}

				uni.navigateTo({
					url: '/pages/mission/feebackList?mission_id=' + data.mission_id + "&keyword_id=" + data.id
				})
			},
			clickBar5() {
				// this.value = 'bar4';
				uni.switchTab({
					url: '/pages/center/income'
				})
			},
		}
	}
</script>

<style scoped>
	.u-page__item__slot-icon {
		width: 40rpx;
		height: 40rpx;
	}

	.list_box {
		height: 50vh;
		max-height: 50vh;
		overflow: hidden;
	}

	.acc_item {
		padding: 10rpx;
		padding-bottom: 0px;
	}

	.acc_plf {
		font-weight: 600;
	}
</style>
